<template>
  <div class="HuikuiInfoBatchFeedback el-card is-always-shadow el-card__body">
    <el-dialog
      title="批量回馈差异原因"
      :visible.sync="dialogVisible"
      @close="closed"
      width="950px">
      <avue-crud
        ref="crud"
        :option="optionTable"
        :data="listTable">
        <template slot="menuLeft">
          SC系统数据对比与回馈
        </template>
      </avue-crud><br/><br/><br/>
      <avue-form :disabled="isReload" :option="option" v-model="formData" @submit="handleSubmit">
        <template  slot="jdReplyReason" slot-scope="scope">
          <el-select v-model="jdReplyReason" placeholder="请选择" style="width: 150px">
            <el-option
              v-for="(item,index) in jdReplyReasonList"
              :key="index"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </template>
        <template slot-scope="scope" slot="menuForm" >
          <el-button type="primary" @click="handleSubmit" >确认</el-button>
          <el-button @click="closed" >返回</el-button>
        </template>
      </avue-form>
    </el-dialog>
  </div>
</template>


<script>
  import {getForm, postForm} from '@/api/gen/gen'
  import ExportJsonExcel from "js-export-excel";
  import {fenExYuangettoFixed,getSysDictItemListToDict,getMappingStatus,getLineName,getStationName} from "../../../../../api/subwayRat/commonCheck";
  import {updateSwAuConductorHierarchyAmountDifferen} from "../../../../../api/stationTiecketManager/shuJuXieChaGuanLi/BOM/CJ/BOMCengJiCY";
  import ElInput from "../../../../../../node_modules/element-ui/packages/input/src/input";
  export default {
    components:{
      ElInput
    },
    data() {
      return {
        jdReplyReason :'',
        replySaleMoney:0,
        replyRechargeMoney:0,
        replyErrorReturnMoney:0,
        optionTable:{},
        listTable:[],
        option:{},
        isReload:true,
        dialogVisible:true,
        formData:{},
        jdReplyReasonList:[]
      }
    },
    created() {
      this.formData = this.$parent.batchFeedbackList[0];
      getSysDictItemListToDict({"type":"JD_REPLY_REASON"}).then((response)=>{
        this.jdReplyReasonList = response.data.data;
      });
      this.getOption();
      this.listTable = this.$parent.batchFeedbackList;
      debugger
    },
    methods: {
      async handleSubmit(){
        if(!this.jdReplyReason || "" == this.jdReplyReason){
          this.$message.warning("请选择回馈差异原因！");
          return;
        }
        let ids=[];
        for(let i=0;i<this.listTable.length;i++){
          ids.push(this.listTable[i].id);
        }
        let p = {
          ids:ids,
          jdReplyReason:this.jdReplyReason,
          jdReplyDetail:this.formData.jdReplyDetail
        };
        await updateSwAuConductorHierarchyAmountDifferen(p).then((response)=>{
        });
        this.$parent.getList();
        this.closed();
      },
      closed(){
        this.dialogVisible=false;
        this.$parent.isShowDiaBatchFeedback=false;
      },
      getOption(){
        this.optionTable = {
          border: true,
          index: true,
          indexLabel: '序号',
          selection: false,
          reserveSelection:false,
          stripe: false,
          menuAlign: 'center',
          menu: false,
          viewBtn: false,
          editBtn: false,
          emptyBtn:false,
          delBtn: false,
          align: 'center',
          addBtn: false,
          column: [{
            fixed: true,
            label: '主键',
            prop: 'id',
            span: 24,
            type: 'input',
            hide: true
          },{
            hide: false,
            label: '线路',
            prop: 'lineCode',
            type: 'select',
            filterable : true,
            search: false,
            formatter: function(row, value , label, column){
              return getLineName(value);
            },
            display: true // 动态显隐控制不能删除
          }, {
            hide: false,
            label: '站点',
            prop: 'stationCode',
            type: 'select',
            filterable : true,
            search: false,formatter: function(row, value , label, column){
              return getStationName(row.lineCode,value);
            },
            display: true// 动态显隐控制不能删除
          },{
            label: '收入日期',
            prop: 'settleTime',
            type: 'datetime',
            format: 'yyyy-MM-dd',
            valueFormat: 'yyyy-MM-dd',
            search: false
          }, {
            label: '售票员',
            prop: 'conductorPersonName',
            search: false,
            hide: false,
          }, {
            label: '员工号',
            prop: 'conductorPersonCode',
            search: false,
            hide: false,
          }, {
            hide: false,
            label: 'BOM编号',
            prop: 'bomCode',
          }, {
            width: 120,
            hide: false,
            label: '设备操作号',
            prop: 'equipmentNumber',
            false: true,
          }, {
            width: 120,
            label: 'SC充值金额',
            prop: 'investAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'investAmount');
            },
            search: false,
            hide: false,
          }, {
            width: 120,
            label: 'SC售票金额',
            prop: 'sellAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'sellAmount');
            },
            search: false,
            hide: false,
          }, {
            width: 120,
            label: 'SC补票金额',
            prop: 'faretkAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'faretkAmount');
            },
            search: false,
            hide: false,
          }, {
            width: 120,
            label: 'LC充值金额',
            prop: 'comparativeInvestAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'comparativeInvestAmount');
            },
            search: false,
            hide: false,
          }, {
            width: 120,
            label: 'LC售票金额',
            prop: 'comparativeSelltkAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'comparativeSelltkAmount');
            },
            search: false,
            hide: false,
          }, {
            width: 120,
            label: 'LC补票金额',
            prop: 'comparativeFaretkAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'comparativeFaretkAmount');
            },
            search: false,
            hide: false,
          }, {
            width: 120,
            label: '充值差异金额',
            prop: 'diffInvestAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'diffInvestAmount');
            },
            search: false,
            hide: false,
          }, {
            width: 120,
            label: '售票差异金额',
            prop: 'diffSelltkAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'diffSelltkAmount');
            },
            search: false,
            hide: false,
          }, {
            width: 120,
            label: '补票差异金额',
            prop: 'diffFaretkAmount',
            formatter:function (row,value , label, column) {
              return fenExYuangettoFixed(row,'diffFaretkAmount');
            },
            search: false,
            hide: false,
          }]
        };
        this.option={
          submitBtn:false,
          emptyBtn:false,
          group:[{
              icon:'',
              label: '',
              // collapse:false,
              prop: 'group',
              column: [{
                label: '机电专业回馈差异原因',
                prop: 'jdReplyReason',
                formslot : true,
                labelWidth:200
              },{
                label: '机电专业详细描述',
                prop: 'jdReplyDetail',
                type:'textarea',
                labelWidth:180
              }]
            }]
        }
      }
    },
    mounted() {
    }
  }
</script>
